<van-popup class="screen-popup footer-popup" v-model="ParamScreen.PopupVisible" round  position="bottom" style="height: 90%;padding-top: 10px;" @open="ScreenPopupOpen" @close="ScreenPopupClose">
	<div class="vam-popup-title" v-if="ParamScreen.data[ParamScreen.LeftActive]" @click="ScreenPopupTitleClick">{{ParamScreen.data[ParamScreen.LeftActive].text}}</div>
	<van-tree-select :items="ParamScreen.data" :main-active-index.sync="ParamScreen.LeftActive" @click-nav="ScreenLeftClick" height="100%">
		<template #content>
			<template v-if="ParamScreen.data[ParamScreen.LeftActive]">
				<template v-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'tag'">
					<!--{template mobile/components/index/screen/tag/temp}-->	
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'classify'">
					<!--{template mobile/components/index/screen/classify/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'color'">
					<!--{template mobile/components/index/screen/color/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'link'">
					<!--{template mobile/components/index/screen/link/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'desc'">
					<!--{template mobile/components/index/screen/desc/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'duration'">
					<!--{template mobile/components/index/screen/duration/temp}-->
				</template>
			
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'size'">
					<!--{template mobile/components/index/screen/size/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'ext'">
					<!--{template mobile/components/index/screen/ext/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'shape'">
					<!--{template mobile/components/index/screen/shape/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'grade'">
					<!--{template mobile/components/index/screen/grade/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'btime'">
					<!--{template mobile/components/index/screen/btime/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'dateline'">
					<!--{template mobile/components/index/screen/dateline/temp}-->
				</template>
				<template v-else-if="ParamScreen.data[ParamScreen.LeftActive]['type'] == 'mtime'">
					<!--{template mobile/components/index/screen/mtime/temp}-->
				</template>
			</template>
		</template>
	</van-tree-select>
	<div class="btn-bottom">
		<van-row gutter="20">
		  <van-col span="12" style="text-align: center;">
			  <van-button round plain type="primary" size="large" @click="ScreenReset">重置</van-button>
		  </van-col>
		  <van-col span="12" style="text-align: center;">
			  <van-button round type="info" size="large" @click="ScreenConfirm">确定</van-button>
		  </van-col>
		</van-row>

	</div>
</van-popup>
<!--{template mobile/components/index/screen/classify/js}-->
<script type="text/javascript">
	var ScreenData = {
		ParamScreen:{
			PopupVisible:false,
			ChangeVal:false,
			LeftActive:0,
			ActiveNum:'',
			dataBadge:['tag','ext','shape','grade'],
			dataTypes:['classify','tag','color','link','desc','duration','size','ext','shape','grade','btime','dateline','mtime'],
			data:[],
			groupdata:{},
			defaultval:{},
			ScreenPost:'',
			value:{
				classify:{
					loading:true,
					data:[],
					activeNames:[],
					value:[],
					valueNode:[],
					explandFids:[],
					realvalue:[],
					DefaultExpandedKeysInit:[]
				},
				tag:{
					loading:true,
					data:{},
					value:[],
					refreshval:{},
					tabActive:'all',
					Post:''
				},
				color:{
					defaultval:['#FFFFFF','#A0E7F7','#4AD1F0','#00B8E3','#007793','#D5D5D5','#998CF8','#4E38F0','#1900D2','#100082','#C0C0C0','#BC8CF8','#8A38F0','#5E00D2','#3A0082','#AAAAAA','#DBA3C5','#C75A9D','#AA2176','#6E0E49','#959595','#E4A9AE','#D45C67','#C21827','#820813','#808080','#EBB4A5','#DE7354','#D0380C','#8B2000','#565656','#F2D2A1','#EBAC4B','#DF8800','#8F5700','#161616','#CCDBA7','#A9C75F','#85AD23','#55710F'],
					value:'',
					persion:50,
				},
				link:{
					value:'',
					input:''
				},
				desc:{
					value:'',
					input:''
				},
				duration:{
					start:'',
					end:'',
					unit:'s'
				},
				size:{
					wstart:'',
					wend:'',
					hstart:'',
					hend:'',
				},
				ext:{
					loading:true,
					value:[],
					data:[]
				},
				shape:{
					loading:true,
					value:[],
					sizemin:'',
					sizemax:'',
					data:[],
					fdata:[
						{val:7,name:'方图'},
						{val:8,name:'横图'},
						{val:5,name:'细长横图'},
						{val:6,name:'细长竖图'},
						{val:9,name:'竖图'},
						{val:1,name:'4:3'},
						{val:2,name:'3:4'},
						{val:3,name:'16:9'},
						{val:4,name:'9:16'}
					]
				},
				grade:{
					loading:true,
					data:[],
					value:[]
				},
				btime:{
					loading:true,
					calendar:false,
					minDate:new Date(2010, 0, 1),
					data:[],
					value:'',
					customvalue:'',
					defaultdate:[]
				},
				dateline:{
					loading:true,
					calendar:false,
					minDate:new Date(2010, 0, 1),
					data:[],
					value:'',
					customvalue:'',
					defaultdate:[]
				},
				mtime:{
					loading:true,
					calendar:false,
					minDate:new Date(2010, 0, 1),
					data:[],
					value:'',
					customvalue:'',
					defaultdate:[]
				}
			}
		}
	};
	
	var ScreenJs = $.extend({},JsScreenClassiyfMethods,{
		ScreenPopupOpen(){
			this.ScreenStorageValdata();
			this.ScreenLeftClick(this.ParamScreen.LeftActive);
		},
		
		ScreenStorageValdata(){
			var param = {};
			var data = JSON.parse(JSON.stringify(this.ParamScreen.value));
			for(var i in data){
				var item = data[i];
				switch(i){
					case 'classify':
						param[i] = item.realvalue;
					break;
					case 'tag':
					case 'ext':
					case 'grade':
					case 'color':
						param[i] = item.value;
					break;
					case 'link':
					case 'desc':
						param[i] = {
							value:item.value,
							input:item.input
						};
					break;
					case 'duration':
						param[i] = {
							start:item.start,
							end:item.end,
							unit:item.unit
						}
					break;
					case 'size':
						param[i] = {
							wstart:item.wstart,
							wend:item.wend,
							hstart:item.hstart,
							hend:item.hend
						};
					break;
					case 'shape':
						param[i] = {
							value:item.value,
							sizemin:item.sizemin,
							sizemax:item.sizemax
						};
					break;
					case 'btime':
					case 'dateline':
					case 'mtime':
						param[i] = {
							value:item.value,
							customvalue:item.customvalue,
						}
					break;
				}
			}
			this.ParamScreen.defaultval = param;
		},
		ScreenPopupTitleClick(){
			this.ParamScreen.PopupVisible = false;
		},
		ScreenLeftClick(index){
			var self = this;
			var item = this.ParamScreen.data[index];
			if(item.type == 'color' || item.type == 'link' || item.type == 'desc' || item.type == 'duration' || item.type == 'size'){
				return false;
			}
			if(item.type == 'tag'){
				if(item.grouptag){
					item.loading = true;
					item.page = 1;
				}else{
					if(!$.isEmptyObject(self.ParamScreen.value.tag.data)){
						self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive].page = 1;
						self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive].loading = true;
					}
					self.ParamScreen.value.tag.loading = true;
				}
			}else{
				self.ParamScreen.value[item.type].loading = true;
			}
			switch(item.type){
				case 'classify':
					self.ScreenGetdataClassify();
				break;
				case 'tag':
					if(item.grouptag){
						item.page = 1;
						item.data = [];
						var param = self.ScreenFinishingparameters();
						self.ScreenGetdataText(param);
					}else{
						var param = self.ScreenFinishingparameters();
						self.ScreenGetdataText(param);
						// if(self.ParamLibrary.activeId){
						// 	self.ScreenGetdataNum(param);
						// }
					}
					
				break;
				case 'ext':
				case 'shape':
				case 'grade':
				case 'btime':
				case 'dateline':
				case 'mtime':
					var param = self.ScreenFinishingparameters();
					self.ScreenGetdataText(param);
				break;
			}
			
		},
		
		
		

		ScreenTagClick(val){
			var index = this.ParamScreen.value.tag.value.indexOf(val);
			if( index == -1){
				this.ParamScreen.value.tag.value.push(val);
			}else{
				this.ParamScreen.value.tag.value.splice(index,1)
			}
			var item = this.ParamScreen.data[this.ParamScreen.LeftActive];
			var arr = [];
			var val = this.ParamScreen.value.tag.value;
			if(item.grouptag){
				var num = 0;
				for(var i in val){
					var id = val[i];
					for(var t in item.data){
						var titem = item.data[t];
						if(parseInt(titem.tid) == parseInt(id)){
							arr.push(id)
							num += 1;
						}
					}
				}
				item.value = arr;
				item.badge = num || '';
			}else{
				item.badge = val.length || '';
			}
		},
		ScreenTagTabsChange(cid,getnum){
			var self = this;
			if(!getnum){
				self.ParamScreen.value.tag.data[cid].page = 1;
				self.ParamScreen.value.tag.data[cid].loading = true;
				self.ParamScreen.value.tag.data[cid].data = [];
				if(self.ParamScreen.value.tag.Post){
					self.ParamScreen.value.tag.Post.abort()
				}
			}
			var ParamData = self.ScreenFinishingparameters();
			if(getnum){
				ParamData['hasnum'] = 1;
			}
			self.ParamScreen.value.tag.Post = $.post(MOD_URL+'&op=ajax&operation=searchmenu_num',ParamData,function(data){
				if(getnum){
					var alltagdata = [];
					for(var i in data.alltagdata){
						var titem = data.alltagdata[i];
						var str = {
							tagname:titem.tagname,
							num:titem.num,
							tid:parseInt(i),
						}
						alltagdata.push(str);
					}
					if(self.ParamScreen.value.tag.data[cid].data){
						var fdata = self.ParamScreen.value.tag.data[cid].data;
						for(var xi in fdata){
							var xiitem  = fdata[xi];
							var num = 0;
							for(var x in alltagdata){
								var xitem = alltagdata[x];
								if(parseInt(xiitem.tid) == parseInt(xitem.tid)){
									num = xitem.num;
								}
							}
							
							self.ParamScreen.value.tag.data[cid].data[xi]['num'] = num;
						}
						self.$forceUpdate();
					}
				}else{
					var alltagdata = [];
					for(var i in data.alltagdata){
						var titem = data.alltagdata[i];
						var str = {
							tagname:titem.tagname,
							tid:parseInt(i),
						}
						alltagdata.push(str);
					}
					self.ParamScreen.value.tag.data[cid].finish = data.finish;
					self.ParamScreen.value.tag.data[cid].loading = false;
					self.ParamScreen.value.tag.data[cid].data = alltagdata;
					self.$nextTick(function(){
						self.ScreenTagScroll();
					});
					self.ScreenTagTabsChange(cid,true)
				}
				
			},'json');
		},
		ScreenTagKeyword(cid,grouptag,getnum){
			var self = this;
			
			if(grouptag){
				if(!self.ParamScreen.data[cid]){
					return false;
				}
			}else{
				if(!self.ParamScreen.value.tag.data[cid]){
					return false;
				}
			}
			
			if(grouptag){
				var item = self.ParamScreen.data[cid];
			}else{
				var item = self.ParamScreen.value.tag.data[cid];
			}
			
			if(!getnum){
				if(grouptag){
					self.$refs['scrollbarTag_'+item.cid].scrollTop = 0;
				}else{
					$('.screen-tag-Scroll')[0].scrollTop = 0;
				}
				item.data = [];
				item.page = 1;
				item.searchloading = true;
				if(self.ParamScreen.value.tag.Post){
					self.ParamScreen.value.tag.Post.abort();
				}
			}
			var ParamData = self.ScreenFinishingparameters();
			if(item.keyword){
				ParamData['tagkeyword'] = item.keyword;
			}
			if(getnum){
				ParamData['hasnum'] = 1;
			}
			
			self.ParamScreen.value.tag.Post = $.post(MOD_URL+'&op=ajax&operation=searchmenu_num',ParamData,function(data){
				if(getnum){
					var alltagdata = [];
					for(var i in data.alltagdata){
						var titem = data.alltagdata[i];
						var str = {
							tagname:titem.tagname,
							tid:parseInt(i),
							num:titem.num
						}
						alltagdata.push(str);
					}
					var fdata = item.data;
					for(var xi in fdata){
						var xiitem  = fdata[xi];
						var num = 0;
						for(var x in alltagdata){
							var xitem = alltagdata[x];
							if(parseInt(xiitem.tid) == parseInt(xitem.tid)){
								num = xitem.num;
							}
						}
						
						item.data[xi]['num'] = num;
					}
					self.$forceUpdate();
				}else{
					var alltagdata = [];
					for(var i in data.alltagdata){
						var titem = data.alltagdata[i];
						var str = {
							tagname:titem.tagname,
							tid:parseInt(i),
						}
						item.data.push(str);
					}
					
					item.finish = data.finish;
					item.searchloading = false;
					self.ScreenTagKeyword(cid,grouptag,true)
				}
				
			},'json');
		},
		ScreenTagClearKeyword(cid,grouptag){
			if(grouptag){
				this.ParamScreen.data[cid].keyword = '';
			}else{
				this.ParamScreen.value.tag.data[cid].keyword = '';
			}
			
			this.ScreenTagKeyword(cid,grouptag);
		},
		ScreenTagScroll(cid){
			var self = this;
			if(cid){
				var item = self.ParamScreen.data[self.ParamScreen.LeftActive];
				$(self.$refs['scrollbarTag_'+cid]).unbind('scroll');
				$(self.$refs['scrollbarTag_'+cid]).bind('scroll',function(){
					if(!item.finish && !item.scrollloading && !item.searchloading && this.scrollHeight-100 < $(this).scrollTop()+this.clientHeight){
						item.page += 1;
						item.scrollloading = true;
						var ParamData = self.ScreenFinishingparameters();
						$.post(MOD_URL+'&op=ajax&operation=searchmenu_num',ParamData,function(data){
							var alltagdata = [];
							for(var i in data.alltagdata){
								var titem = data.alltagdata[i];
								var str = {
									tagname:titem.tagname,
									tid:parseInt(i),
								}
								item.data.push(str);
							}
							item.finish = data.finish;
							item.scrollloading = false;
							self.ScreenTagScrollSearchmenu(cid,ParamData);
						},'json');
					}
				});
			}else{
				
				// if(self.ParamLibrary.activeId){
				var item = self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive];
				$('.screen-tag-Scroll').unbind('scroll');
				$('.screen-tag-Scroll').bind('scroll',function(){
					if(!item.finish && !item.scrollloading && !item.searchloading && this.scrollHeight-100 < $(this).scrollTop()+this.clientHeight){
						item.page += 1;
						item.scrollloading = true;
						var ParamData = self.ScreenFinishingparameters();
						if(item.keyword){
							ParamData['tagkeyword'] = item.keyword;
						}
						$.post(MOD_URL+'&op=ajax&operation=searchmenu_num',ParamData,function(data){
							var alltagdata = [];
							for(var i in data.alltagdata){
								var titem = data.alltagdata[i];
								var str = {
									tagname:titem.tagname,
									tid:parseInt(i),
								}
								item.data.push(str);
							}
							item.finish = data.finish;
							item.scrollloading = false;
							self.ScreenTagScrollSearchmenu('',ParamData);
						},'json');
					}
				});
			}
			
		},
		ScreenTagScrollSearchmenu(cid,ParamData){
			var self = this;
			if(cid){
				var item = self.ParamScreen.data[self.ParamScreen.LeftActive];
			}else{
				var item = self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive];
			}
			ParamData['hasnum'] = 1;
			$.post(MOD_URL+'&op=ajax&operation=searchmenu_num',ParamData,function(data){
				var alltagdata = [];
				for(var i in data.alltagdata){
					var titem = data.alltagdata[i];
					var str = {
						tagname:titem.tagname,
						num:titem.num,
						tid:parseInt(i),
					}
					alltagdata.push(str);
				}
				for(var x in item.data){
					var xitem = item.data[x];
					for(var xi in alltagdata){
						var xiitem = alltagdata[xi];
						if(parseInt(xitem.tid) == parseInt(xiitem.tid)){
							item.data[x]['num'] = xiitem.num;
						}
					}
				}
				self.$forceUpdate();
			},'json');
		},
		ScreenColorClick(val){
			var self = this;
			if(this.ParamScreen.value.color.value.toUpperCase() != val.toUpperCase()){
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
				this.ParamScreen.value.color.value = val.toUpperCase();
				
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
				this.ParamScreen.value.color.value = '';
			}
		},
		ScreenColorInput(val){
			if(val){
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
			}
		},
		ScreenColorInputClear(){
			this.ParamScreen.value.color.value = '';
			this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
		},
		ScreenColorInputBlur(){
			var val = this.ParamScreen.value.color.value;
		},
		ScreenlinkClick(val){
			if(this.ParamScreen.value.link.value != val){
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
				this.ParamScreen.value.link.value = val;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
				this.ParamScreen.value.link.value = '';
			}
		},
		ScreenDescClick(val){
			if(this.ParamScreen.value.desc.value != val){
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
				this.ParamScreen.value.desc.value = val;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
				this.ParamScreen.value.desc.value = '';
			}
		},
		ScreenDurationChange(val){
			if(this.ParamScreen.value.duration.start || this.ParamScreen.value.duration.end){
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
			}
		},
		ScreenSizeChange(){
			if(this.ParamScreen.value.size.wstart || this.ParamScreen.value.size.wend || this.ParamScreen.value.size.hstart || this.ParamScreen.value.size.hend){
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
			}
		},
		ScreenExtClick(val){
			var index = this.ParamScreen.value.ext.value.indexOf(val);
			if( index == -1){
				this.ParamScreen.value.ext.value.push(val);
			}else{
				this.ParamScreen.value.ext.value.splice(index,1)
			}
			if(this.ParamScreen.value.ext.value && this.ParamScreen.value.ext.value.length){
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = this.ParamScreen.value.ext.value.length;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = '';
			}
		},

		ScreenShapeClick(val){
			var index = this.ParamScreen.value.shape.value.indexOf(val);
			if( index == -1){
				this.ParamScreen.value.shape.value.push(val);
			}else{
				this.ParamScreen.value.shape.value.splice(index,1)
			}
			if(this.ParamScreen.value.shape.value && this.ParamScreen.value.shape.value.length){
				var len = this.ParamScreen.value.shape.value.length;
				if(this.ParamScreen.value.shape.value.indexOf('custom')>-1 && (!this.ParamScreen.value.shape.sizemin || !this.ParamScreen.value.shape.sizemax)){
					len = len -1;
				}
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = len || '';
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = '';
			}
		},
		ScreenShapeCustomInput(){
			if(this.ParamScreen.value.shape.sizemin && this.ParamScreen.value.shape.sizemax){
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = this.ParamScreen.value.shape.value.length;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = this.ParamScreen.value.shape.value.length-1;
			}
		},

		ScreenGradeClick(val){
			var index = this.ParamScreen.value.grade.value.indexOf(val);
			if( index == -1){
				this.ParamScreen.value.grade.value.push(val);
			}else{
				this.ParamScreen.value.grade.value.splice(index,1)
			}
			if(this.ParamScreen.value.grade.value && this.ParamScreen.value.grade.value.length){
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = this.ParamScreen.value.grade.value.length;
			}else{
				this.ParamScreen.data[this.ParamScreen.LeftActive].badge = '';
			}
		},
		ScreenTimeClick(type,val){
			if(this.ParamScreen.value[type].value != val){
				this.ParamScreen.value[type].value = val;
				if(val == '自定义'){
					var start = new Date();
					var end = new Date();
					start.setTime(start.getTime() - 3600 * 1000 * 24);
					var defaulttime = [ new Date(start.getFullYear(), start.getMonth()+1, start.getDate()),new Date(end.getFullYear(), end.getMonth()+1, end.getDate())];
					this.ParamScreen.value[type].defaultdate = defaulttime;
					var fstart = this.ScreenFormatDate(start);
					var fend = this.ScreenFormatDate(end);
					this.ParamScreen.value[type].customvalue = `${fstart} 至 ${fend}`;
				}
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;
			}else{
				this.ParamScreen.value[type].value = '';
				this.ParamScreen.data[this.ParamScreen.LeftActive].dot = false;
			}
		},
		ScreenBtimeCalendarConfirm(data){
			var fstart = this.ScreenFormatDate(data[0]);
			var fend = this.ScreenFormatDate(data[1]);
			this.ParamScreen.value.btime.customvalue = `${fstart} 至 ${fend}`;
			this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;	
			this.ParamScreen.value.btime.calendar = false;
		},
		ScreenDatelineCalendarConfirm(data){
			var fstart = this.ScreenFormatDate(data[0]);
			var fend = this.ScreenFormatDate(data[1]);
			this.ParamScreen.value.dateline.customvalue = `${fstart} 至 ${fend}`;
			this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;	
			this.ParamScreen.value.dateline.calendar = false;
		},
		ScreenMtimeCalendarConfirm(data){
			var fstart = this.ScreenFormatDate(data[0]);
			var fend = this.ScreenFormatDate(data[1]);
			this.ParamScreen.value.mtime.customvalue = `${fstart} 至 ${fend}`;
			this.ParamScreen.data[this.ParamScreen.LeftActive].dot = true;	
			this.ParamScreen.value.mtime.calendar = false;
		},
		ScreenFormatDate(date) {
			return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
		},
		ScreenGetdataNum(ParamData){
			var self = this;
			$.post(MOD_URL+'&op=ajax&operation=search_menu',ParamData,function(data){
				if(data.catdata){
					for(var i in data.catdata){
						var item = data.catdata[i];
						var cid = item.cid;
						if(parseInt(cid) == 0){
							cid = 'all';
						}
						if(self.ParamScreen.value.tag.data[cid]){
							self.ParamScreen.value.tag.data[cid].num = item.num;
						}
					}
				}
			},'json');
		},
		ScreenGetdataText(ParamData,getnum){
			var self = this;
			if(!getnum && self.ParamScreen.ScreenPost){
				self.ParamScreen.ScreenPost.abort();
			}
			if(getnum){
				ParamData['hasnum'] = 1;
			}
			self.ParamScreen.ScreenPost = $.post(MOD_URL+'&op=ajax&operation=searchmenu_num',ParamData,function(data){
				self.ScreenGetdataAssignment(data,getnum,ParamData);
			},'json');
		},
		ScreenGetdataAssignment(data,getnum,ParamData){
			var self = this;
			var item = self.ParamScreen.data[self.ParamScreen.LeftActive];
			var type = item.type;
			if(type == 'ext'){
				var arr = [];
				for(var i in data){
					arr.push(data[i]);
				}
				self.ParamScreen.value.ext.data = arr;
				self.ParamScreen.value.ext.loading = false;
			}else if(type == 'tag'){
				
				if(getnum){
					var alltagdata = [];
					for(var i in data.alltagdata){
						var titem = data.alltagdata[i];
						var str = {
							tagname:titem.tagname,
							tid:parseInt(i),
							num:titem.num,
						}
						alltagdata.push(str);
					}
					if(self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive]){
						var fdata = self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive];
						for(var xi in fdata.data){
							var xiitem  = fdata.data[xi];
							var num = 0;
							for(var x in alltagdata){
								var xitem = alltagdata[x];
								
								if(parseInt(xiitem.tid) == parseInt(xitem.tid)){
									num = xitem.num;
								}
							}
							self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive].data[xi]['num'] = num;
						}
						self.$forceUpdate();
					}
				}else{
					var alltagdata = [];
					for(var i in data.alltagdata){
						var titem = data.alltagdata[i];
						var str = {
							tagname:titem.tagname,
							tid:parseInt(i),
						}
						alltagdata.push(str);
					}
					var arr = {};
					arr['all'] = {
						catname:'全部',
						num:0,
						cid:'all',
						page:1,
						keyword:'',
						loading:self.ParamScreen.value.tag.tabActive == 'all'?false:true,
						scrollloading:false,
						searchloading:false,
						data:self.ParamScreen.value.tag.tabActive == 'all'?alltagdata:[],
						finish:self.ParamScreen.value.tag.tabActive == 'all'?data.finish:false
					};
					if(data.catdata){
						for(var x in data.catdata){
							var titem = data.catdata[x];
							var str = {
								catname:titem.catname,
								num:0,
								cid:titem.cid,
								scrollloading:false,
								searchloading:false,
								keyword:'',
								page:1,
								loading:self.ParamScreen.value.tag.tabActive == titem.cid?false:true,
								data:self.ParamScreen.value.tag.tabActive == titem.cid?alltagdata:[],
								finish:self.ParamScreen.value.tag.tabActive == titem.cid?data.finish:false
							}
							arr[titem.cid] = str;
						}
					}
					self.ParamScreen.value.tag.data = arr;
					if(item.grouptag){
						item.data = alltagdata
						item.loading = false;
						item.finish = data.finish;
						self.$nextTick(function(){
							self.ScreenTagScroll(item.cid);
						});
					}else{
						self.ParamScreen.value.tag.loading = false;
						self.$nextTick(function(){
							self.ScreenTagScroll();
						});
					}
					self.ScreenGetdataText(ParamData,true);
				}
			}else if(type == 'shape'){
				var arr = [];
				for(var i in data){
					arr.push(data[i]);
				}
				if(getnum){
					for(var s in self.ParamScreen.value.shape.data){
						var sitem = self.ParamScreen.value.shape.data[s];
						var num = 0;
						for(var a in arr){
							if(parseInt(arr[a].val) == parseInt(sitem.val)){
								num = arr[a].num;
							}
						}
						if(sitem.val != 'custom'){
							sitem['num'] = num;
						}
					}
					self.$forceUpdate();
				}else{
					arr.push({
						lablename:'自定义',
						val:'custom',
						num:''
					})
					self.ParamScreen.value.shape.data = arr;
					self.ParamScreen.value.shape.loading = false;
					self.ScreenGetdataText(ParamData,true);	
				}
				
			}else if(type == 'grade'){
				var arr = [];
				var not = {};
				for(var i in data){
					if(parseInt(data[i].grade)){
						arr.push({
							num:data[i].num,
							grade:parseInt(data[i].grade),
						});
					}else{
						not = {
							num:data[i].num,
							grade:parseInt(data[i].grade),
						}
					}
					
				}
				if(!$.isEmptyObject(not)){
					arr.push(not);
				}
				self.ParamScreen.value.grade.data = arr;
				self.ParamScreen.value.grade.loading = false;
			}else if(type == 'btime' || type == 'dateline' || type == 'mtime'){
				var arr = [];
				for(var i in data){
					arr.push({
						num:data[i].num,
						label:data[i].label,
						val:data[i].val
					});
				}
				if(arr.length){
					arr.push({
						num:'',
						label:'自定义',
						val:'custom'
					});
				}
				self.ParamScreen.value[type].data = arr;
				self.ParamScreen.value[type].loading = false;
			}
		},
		ScreenFinishingparameters(){
			var self = this;
			var item = self.ParamScreen.data[self.ParamScreen.LeftActive];
			var type = item.type;
			var param = {};
			param['skey'] = type;
			param['hassub'] = 1;
			if(self.ParamSearch.keyword){
				param['keyword'] = self.ParamSearch.keyword;
			}
			if(self.ParamLibrary.activeId){
				param['appid'] = self.ParamLibrary.activeId;
			}
			if(type == 'tag'){
				if(item.grouptag){
					param['skey'] = 'tag';
					param['cid'] = item.cid;
					param['page'] = item.page;
				}else{
					if(!$.isEmptyObject(self.ParamScreen.value.tag.data)){
						if(self.ParamLibrary.activeId){
							var itemtag = self.ParamScreen.value.tag.data[self.ParamScreen.value.tag.tabActive];
						}else{
							var itemtag = self.ParamScreen.value.tag.data['all'];
						}
						param['cid'] = self.ParamScreen.value.tag.tabActive=='all'?'':self.ParamScreen.value.tag.tabActive;
						param['page'] = itemtag.page;
					}
				}
			}
			for(var i in self.ParamScreen.value){
				var Pitem = self.ParamScreen.value[i];
				switch(i){
					case 'tag':
						if(Pitem.value && Pitem.value.length){
							// if(item.grouptag){
							// 	var tids = [];
							// 	for(var v in Pitem.value){
							// 		var ftid = parseInt(Pitem.value[v]);
							// 		var status = true;
							// 		if(item.value.indexOf(ftid) > -1){
							// 			status = false;
							// 		}
							// 		if(status){
							// 			tids.push(ftid);
							// 		}
							// 	}
							// 	if(tids.length){
							// 		param['tag'] = tids.join(',');
							// 	}
							// }else{
							// 		param['tag'] = Pitem.value.join(',');
							// }
							param['tag'] = Pitem.value.join(',');
						}
					break;
					case 'link':
						if(Pitem.value && type != i){
							param['link'] = Pitem.value;
							if(parseInt(Pitem.value)){
								param['linkval'] = Pitem.input;
							}
						}
					break;
					case 'desc':
						if(Pitem.value && type != i){
							param['desc'] = Pitem.value;
							if(parseInt(Pitem.value)){
								param['descval'] = Pitem.input;
							}
						}
					break;
					case 'duration':
						if((Pitem.start || Pitem.end) && type != i){
							param['duration'] = Pitem.start+'_'+Pitem.end;
							param['dunit'] = Pitem.unit;
						}
					break;
					case 'size':
						if(Pitem.wstart || Pitem.wend){
							param['wsize'] = Pitem.wstart+'_'+Pitem.wend;
						}
						if(Pitem.hstart || Pitem.hend){
							param['hsize'] = Pitem.hstart+'_'+Pitem.hend;
						}
					break;
					case 'shape':
						if(Pitem.value && Pitem.value.length && type != i){
							var index = Pitem.value.indexOf('custom');
							var newval = JSON.parse(JSON.stringify(Pitem.value));
							if(index > -1){
								newval.splice(index,1);
							}
							param['shape'] = newval.join(',');
							if(index > -1 && Pitem.sizemin && Pitem.sizemax){
								param['shapesize'] = Pitem.sizemin+':'+Pitem.sizemax;
							}
						}
					break;
					case 'btime':
					case 'dateline':
					case 'mtime':
						if(Pitem.value && type != i){
							if(Pitem.value == '自定义'){
								if(Pitem.customvalue){
									var time = Pitem.customvalue.split('至');
									param[i] = $.trim(time[0])+'_'+$.trim(time[1]);
								}
							}else{
								param[i] = GetDateVal(Pitem.value);
							}
						}
					break;
					case 'color':
						if(Pitem.value){
							param['color'] = Pitem.value;
							param['persion'] = Pitem.persion;
						}
					break;
					case 'classify':
						if(Pitem.value && Pitem.value.length && type != i){
							param['fids'] = Pitem.realvalue.join(',');
						}
					break;
					default:
						// grade,ext,classify
						if(Pitem.value && Pitem.value.length && type != i){
							param[i] = Pitem.value.join(',');
						}
					break;
				}
	
			}
			return param;
		},
		
		ScreenConfirm(){
			this.ParamScreen.PopupVisible = false;
		},
		ScreenReset(){
			for(var i in this.ParamScreen.data){
				var item = this.ParamScreen.data[i];
				var type = item.type;
				var fitem = this.ParamScreen.value[type];
				switch(type){
					case 'classify':
						fitem.value = [];
						fitem.activeNames = [];
						fitem.valueNode = [];
						fitem.explandFids = [];
						fitem.realvalue = [];
						fitem.DefaultExpandedKeysInit = [];
						item.dot = false;
					break;
					case 'ext':
					case 'grade':
						fitem.value = [];
						item.badge = '';
					break;
					case 'tag':
						if(item.grouptag){
							item.value = [];
						}
						fitem.value = [];
						item.badge = '';
					break;
					case 'color':
						fitem.value = '';
						item.dot = false;
					break;
					case 'link':
					case 'desc':
						fitem.value = '';
						fitem.input = '';
						item.dot = false;
					break;
					case 'duration':
						fitem.start = '';
						fitem.end = '';
						fitem.unit = 's';
						item.dot = false;
					break;
					case 'size':
						fitem.wstart = '';
						fitem.wend = '';
						fitem.hstart = '';
						fitem.hend = '';
						item.dot = false;
					break;
					case 'shape':
						fitem.value = [];
						item.sizemin = '';
						item.sizemin = '';
						item.badge = '';
					break;
					case 'btime':
					case 'dateline':
					case 'mtime':
						fitem.value = '';
						fitem.customvalue = '';
						item.dot = false;
					break;
				}
			}
			this.ParamScreen.ActiveNum = '';
			this.ScreenLeftClick(this.ParamScreen.LeftActive);
			// this.CommonSetBadge();
			// this.ScreenLeftClick(this.ParamScreen.LeftActive);
		},
		ScreenPopupClose(){
			this.ScreenPopupChange();
			if(this.ParamScreen.ChangeVal){
				this.CommonSetFooterBadge();
				this.CommonhandleHash();
			}
		},
		ScreenPopupChange(){
			var change = false;
			for(var i in this.ParamScreen.defaultval){
				var val = JSON.parse(JSON.stringify(this.ParamScreen.defaultval[i]));
				var item = JSON.parse(JSON.stringify(this.ParamScreen.value[i]));
				if(i == 'link' || i == 'desc'){
					if(item.value != val.value){
						change = true;
						break;
					}
					if(parseInt(val.value) > 0  && val.input != item.input){
						change = true;
						break;
					}
				}else if(i == 'duration'){
					if(val.start != item.start || val.end != item.end){
						change = true;
						break;
					}
			
					if((item.end || item.start) && val.unit != item.unit){
						change = true;
						break;
					}
				}else if(i == 'size'){
					if(val.wstart != item.wstart || val.wend != item.wend || val.hstart != item.hstart || val.hend != item.hend){
						change = true;
						break;
					}
				}else if(i == 'shape'){
					if(JSON.stringify(val.value) != JSON.stringify(item.value)){
						change = true;
						break;
					}
					if(item.value.indexOf('custom')>-1 && item.sizemin && item.sizemax && (val.sizemin != item.sizemin || val.sizemax != item.sizemax)){
						change = true;
						break;
					}
				}else if(i == 'btime' || i == 'dateline' || i == 'mtime'){
					if(item.value != '自定义' && val.value != item.value){
						change = true;
						break;
					}
					if(item.value == '自定义' && item.customvalue && val.customvalue != item.customvalue){
						change = true;
						break;
					}
				}else if(i == 'classify'){
					
					if(JSON.stringify(val) != JSON.stringify(item.realvalue)){
						change = true;
						break;
					}
				}else{
					if(JSON.stringify(val) != JSON.stringify(item.value)){
						change = true;
						break;
					}
				}
			}
			this.ParamScreen.ChangeVal = change;
		}
	});
	
</script>

